<template>
	<view class="reset clearfix">
		<cu-custom isBack bgColor="text-black"></cu-custom>
		<form class="block clearfix  padding padding-bottom-lg radius-sm overflow-hidden   py20">
			<view class="flex  flex-direction login-box ">
				<view class="discenter"><image src="/static/login/logo.png" class="login-logo" mode=""></image></view>
				<view class="mt10 discenter f16 fwb">邻里</view>
				<view class="text-xxl text-bold py20">{{ i18n.title }}</view>
				<evan-form hide-required-asterisk ref="form" :model="form">
					<evan-form-item prop="email">
						<view class="cu-form-group mh65 bb1 solid-bottom padding-lr-xs" slot="formItem">
							<input type="number" :maxlength="11" placeholder-class="text-info" :placeholder="i18n.phone[0]" name="tel" v-model.trim="form.tel" />
						</view>
					</evan-form-item>
					<evan-form-item prop="card">
						<view class="cu-form-group mh65 bb1 solid-bottom padding-lr-xs" slot="formItem">
							<input :maxlength="6" placeholder-class="text-info" :placeholder="i18n.verifyCode[0]" name="card" v-model.trim="form.card" />
							<button class="cu-btn padding-lr-xs margin-left bg-transparent text-danger" :disabled="disabled" @click="getCode">{{ codeText }}</button>
						</view>
					</evan-form-item>
					<evan-form-item prop="pwd">
						<view class="cu-form-group mh65 bb1 solid-bottom padding-lr-xs" slot="formItem">
							<input password :maxlength="16" placeholder-class="text-info" placeholder="设置新密码" name="pwd" v-model.trim="form.pwd" />
						</view>
					</evan-form-item>
					<evan-form-item prop="pwd1">
						<view class="cu-form-group mh65 bb1 solid-bottom padding-lr-xs" slot="formItem">
							<input password :maxlength="16" placeholder-class="text-info" placeholder="确认新密码" name="pwd1" v-model.trim="form.pwd1" />
						</view>
					</evan-form-item>
				</evan-form>
				
				<button :disabled="isLoading" @click="formValidate" type class="cu-btn round margin-top-xl margin-lr-sm block lg button-jianbian text-white">
					<text v-if="isLoading" class="cuIcon-loading2 cuIconfont-spin margin-right-sm"></text>
					重置密码
				</button>
				
				<view class="cu-form-group margin-lr-xs justify-center f12">
					<view class="flex align-center">
						<view class="margin-right-xs">已{{ i18n.isAccount }},</view>
						<view class="register text-danger padding-tb-xs" @click="pushPage('/pages/login/login')">{{ i18n.goLogin }}></view>
					</view>
				</view>
			</view>
		</form>
	</view>
</template>

<script>
import { mapState, mapActions } from 'vuex'
import verifyCode from '@/mixins/verifyCode'
export default {
	mixins: [verifyCode],
	data() {
		return {
			form: {
				tel: '',
				card: '',
				pwd: '',
				pwd1: ''
			}
		}
	},
	computed: {
		
	},
	methods: {
		async formSubmit(e) {
			if(this.form.tel==''){
				uni.showToast({
					title:'请输入手机号',
					icon:'none'
				})
				return false
			}
			if(this.form.card==''){
				uni.showToast({
					title:'请输入验证码',
					icon:'none'
				})
				return false
			}
			if(this.form.pwd==''){
				uni.showToast({
					title:'请设置登录密码',
					icon:'none'
				})
				return false
			}
			if(this.form.pwd1==''){
				uni.showToast({
					title:'请再次输入登录密码',
					icon:'none'
				})
				return false
			}
			if(this.form.pwd1!=this.form.pwd){
				uni.showToast({
					title:'两次密码不一致',
					icon:'none'
				})
				return false
			}
			await this.$http.post('login.resetPassword', this.form, { isAuth: false, tipConfig: { storeLoading: true, isSuccessTip: true } })
			setTimeout(() => {
				this.$Router.back()
			}, 800)
		}
	}
}
</script>

<style lang="less">
	.login-logo{
		width: 125rpx;
		height: 125rpx;
	}
	.login-box{
		width: 100%;
		margin: auto;
		
		position: relative;
		z-index: 1;
		padding: 40rpx 0rpx;
	}
	.login-line{
		width: 135rpx;
		height: 2rpx;
		background-color: #ECECEC;
	}
</style>
